<template>
	<view class="content poRel">
		<view style="height: 30rpx;"></view>
		<view class="wid90 mar">
			<!-- <view class="fowe800 foSi30">项目评分</view>
			<view class="mar-top30 dis disAl">
				<block v-for="(item, index) in 5" :key="index">
					<uni-icons v-if="xmpj >= index+1" type="star-filled" size="50rpx" color="#D81E06" @click="xmpj = index+1"></uni-icons>
					<uni-icons v-if="xmpj < index+1" type="star" size="50rpx" color="#000000" @click="xmpj = index+1"></uni-icons>
				</block>
			</view>
			<view class="fowe800 foSi30 mar-top30">评价内容</view>
			<view class="mar-top30 borRad10" style="background-color: #EEEEEE;padding: 30rpx 0;">
				<textarea class="wid90 mar foSi30" v-model="xmText" 
					style="height: 144rpx;" placeholder-style="color: #5B5B5B" placeholder="写下您的评价吧~"/>
			</view>
			<view style="border: 1rpx dashed #E5E5E5;margin-top: 50rpx;"></view> -->
			<view class="fowe800 foSi30">技师评分</view>
			<view class="mar-top30 dis disAl">
				<block v-for="(item, index) in 5" :key="index">
					<uni-icons v-if="jspj >= index+1" type="star-filled" size="50rpx" color="#D81E06" @click="jspj = index+1"></uni-icons>
					<uni-icons v-if="jspj < index+1" type="star" size="50rpx" color="#000000" @click="jspj = index+1"></uni-icons>
				</block>
			</view>
			<view class="fowe800 foSi30 mar-top30">评价内容</view>
			<view class="mar-top30 borRad10" style="background-color: #EEEEEE;padding: 30rpx 0;">
				<textarea class="wid90 mar foSi30" v-model="jsText" 
					style="height: 144rpx;" placeholder-style="color: #5B5B5B" placeholder="写下您的评价吧~"/>
			</view>
		</view>
		<view style="height: 140rpx;"></view>
		<view class="poFix wid100 bacFFF" style="height: 120rpx;bottom: 0;">
			<view class="dis disAl disJuC wid90 mar hei100">
				<view class="hei86 dis disAl disJuC borRad40 coFFF foSi30 fowe600" @click="tijiao"
					style="width: 466rpx;" :style="'background-color: '+theme.main_color+';'">提交评价</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: this.global.url,
				xmText: '',
				jsText: '',
				xmpj: 0,
				jspj: 0,
				id: '',
				tech_id: '',
				order_id: '',
				theme: null
			}
		},
		onLoad(option) {
			// this.id = option.id
			this.tech_id = option.tech_id
			this.order_id = option.order_id
			this.theme = uni.getStorageSync('theme')
		},
		methods: {
			tijiao(){
				var that = this
				if(that.jspj == 0){return uni.showToast({title: '请给技师评分',icon: 'error',duration: 2000}) }
				if(!that.jsText){return uni.showToast({title: '请输入评价',icon: 'error',duration: 2000}) }
				uni.request({
					url: that.global.url + 'api/qianyu_smfw/technician/comment_add',
					method: "POST",
					header: {
						'site-id': that.global.site_id,//自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						tech_id: that.tech_id,
						star: that.jspj,
						content: that.jsText,
						order_id: that.order_id
					},
					success(res) {
						let result = res.data
						if (result.code == 1) {
							uni.navigateBack(1)
						}else{
							uni.showToast({
								title: result.msg,
								//将值设置为 success 或者直接不用写icon这个参数
								icon: 'error',
								//显示持续时间为 2秒
								duration: 2000
							}) 
						}
					}
				})
			},
			tiaozhuan(url) {
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style>
	.content {
		min-height: 100vh;
	}
</style>